<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">

<h:head>
	<title>祖龙娱乐  - BI系统</title>
	<link href="../../css/component.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="../../js/highcharts.js"></script>
	<script type="text/javascript" src="../../js/drawChart.js"></script>
</h:head>

<h:body>
	<ui:param name="bean" value="#{channelDataAction}" />
	
	<span class="pagetitle">市场数据分析 —— 实时:渠道数据</span>
	<p:separator />
	
	<!-- 右侧页面顶部查询部分 -->
	<h:form id="fsearch">
	    <h:panelGrid columns="7">
			<p:poll interval="20" listener="#{bean.search()}" update=":dform" />
			<p:growl id="growl" showDetail="true" sticky="true" />
			<h:outputLabel value="查看日期：" />
	        <p:calendar value="#{bean.lookDate}" mode="popup" pattern="yyyy-MM-dd">
	        </p:calendar>
	        <p:selectCheckboxMenu id="menuAgent" value="#{bean.selectedAgent}" label="代理商"
	                              filter="true" filterMatchMode="startsWith" style="width:150px">
	        	<f:selectItems value="#{bean.agent}" />
	        </p:selectCheckboxMenu>
	        <p:selectManyButton id="menuPlatform" value="#{bean.selectedPlatform}" label="平台"
	                              filter="true" filterMatchMode="startsWith" style="width:150px">
	        	<f:selectItems value="#{bean.platform}" />
	        </p:selectManyButton>
	        <p:commandButton value="查询" action="#{bean.search()}" update=":data" ajax="false" />
        </h:panelGrid>
	</h:form>
	<br />

	<!-- 数据展示部分，包含表格和图表 -->
	<h:form id="dform">
		<div class="data" id="data">
			<p:panel id="panel4" header="实时对比数据" style="margin-bottom:10px;" rendered="true">
                <p:tabView>
                    <p:tab title="激活设备">
                        <p:dataGrid id="chart1" var="c" value="#{bean.lineChart1}" columns="1" layout="grid">
                            <p:panel style="text-align:center">
                                <h:panelGrid columns="1" style="width:100%">
                                    <div id="highchartChart1" style="width:100%;height:300px; border:0;">
                                        <script type="text/javascript">
                                            generateChart('#{c.jsonStr}', '#{c.jsonType}', '1');
                                        </script>
                                    </div>
                                </h:panelGrid>
                            </p:panel>
                        </p:dataGrid>
                    </p:tab>
                    <p:tab title="新增设备">
                        <p:dataGrid id="chart2" var="c" value="#{bean.lineChart2}" columns="1" layout="grid">
                            <p:panel style="text-align:center">
                                <h:panelGrid columns="1" style="width:100%">
                                    <div id="highchartChart2" style="width:90%;height:300px; border:0;">
                                        <script type="text/javascript">
                                            generateChart('#{c.jsonStr}', '#{c.jsonType}', '2');
                                        </script>
                                    </div>
                                </h:panelGrid>
                            </p:panel>
                        </p:dataGrid>
                    </p:tab>
                    <p:tab title="新增账号">
                        <p:dataGrid id="chart3" var="c" value="#{bean.lineChart3}" columns="1" layout="grid">
                            <p:panel style="text-align:center">
                                <h:panelGrid columns="1" style="width:100%">
                                    <div id="highchartChart3" style="width:90%;height:300px; border:0;">
                                        <script type="text/javascript">
                                            generateChart('#{c.jsonStr}', '#{c.jsonType}', '3');
                                        </script>
                                    </div>
                                </h:panelGrid>
                            </p:panel>
                        </p:dataGrid>
                    </p:tab>
                    <p:tab title="新增付费">
                        <p:dataGrid id="chart4" var="c" value="#{bean.lineChart4}" columns="1" layout="grid">
                            <p:panel style="text-align:center">
                                <h:panelGrid columns="1" style="width:100%">
                                    <div id="highchartChart4" style="width:90%;height:300px; border:0;">
                                        <script type="text/javascript">
                                            generateChart('#{c.jsonStr}', '#{c.jsonType}', '4');
                                        </script>
                                    </div>
                                </h:panelGrid>
                            </p:panel>
                        </p:dataGrid>
                    </p:tab>
                </p:tabView>
            </p:panel>
			
			<p:accordionPanel activeIndex="0">
				<p:tab title="小时数据">
				    <p:dataTable id="dlist11" var="l" value="#{bean.payHourDatas}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}" rowsPerPageTemplate="15,30,100" rows="30" style="text-align:center;">
						<f:facet name="{Exporters}">
				        	<h:commandLink styleClass="exporter">
						        <p:graphicImage url="/resources/images/excel.png" height="25px"/>
						        <p:dataExporter type="xls" target="dlist11" fileName="payTrendData-#{pageHelper.getNewDateDetailStr()}"/>
						    </h:commandLink>
					    </f:facet>
						<p:column headerText="时间" styleClass="column grcnewUser" sortBy="#{l.dateStr}">
							<h:outputLabel value="#{l.dateStr}" />
						</p:column>
						<p:column headerText="点击设备" styleClass="column grcnewUser" sortBy="#{l.clkEquipment}">
							<h:outputLabel value="#{l.clkEquipment}" />
						</p:column>
						<p:column headerText="激活设备" styleClass="column grcnewUser" sortBy="#{l.actEquipment}">
							<h:outputLabel value="#{l.actEquipment}" />
						</p:column>
						<p:column headerText="实际激活" styleClass="column grcnewUser" sortBy="#{l.newActive}">
							<h:outputLabel value="#{l.newActive}" />
						</p:column>
						<p:column headerText="新增设备" styleClass="column grcnewUser" sortBy="#{l.newEquipment}">
							<h:outputLabel value="#{l.newEquipment}" />
						</p:column>
						<p:column headerText="新增/激活" styleClass="column grcnewUser" sortBy="#{l.accountActive}">
							<h:outputLabel value="#{l.accountActive}" />
						</p:column>
						<p:column headerText="新增账号数" styleClass="column grcnewUser" sortBy="#{l.newAccount}">
							<h:outputLabel value="#{l.newAccount}" />
						</p:column>
						<p:column headerText="新增付费账号" styleClass="column grcnewUser" sortBy="#{l.newPayAccount}">
							<h:outputLabel value="#{l.newPayAccount}" />
						</p:column>
						<p:column headerText="新增付费金额" styleClass="column grcnewUser" sortBy="#{l.newPay}">
							<h:outputLabel value="#{l.newPay}" />
						</p:column>
						<p:column headerText="新增付费率" styleClass="column grcnewUser" sortBy="#{l.newPayRate}">
							<h:outputLabel value="#{l.newPayRate}" />
						</p:column>
						<p:column headerText="ARPU" styleClass="column grcnewUser" sortBy="#{l.arpu}">
							<h:outputLabel value="#{l.arpu}" />
						</p:column>
					</p:dataTable>
		        </p:tab>
		    </p:accordionPanel>
		    <br/>
		    <p:panel id="panel2" header="实时渠道数据" style="margin-bottom:10px;">
			    <h:panelGrid columns="9">
			        <p:selectCheckboxMenu id="menuAffiliation" value="#{bean.selectedAffiliation}" label="归属"
			                              filter="true" filterMatchMode="startsWith" style="width:150px">
			            <f:selectItems value="#{bean.affiliation}" />
			        </p:selectCheckboxMenu>
			        <p:selectCheckboxMenu id="menuChannelName" value="#{bean.selectedChannelName}" label="渠道名称"
			                              filter="true" filterMatchMode="startsWith" style="width:150px">
			            <f:selectItems value="#{bean.channelName}" />
			        </p:selectCheckboxMenu>
			        <p:selectCheckboxMenu id="menuPaytype" value="#{bean.selectedPaytype}" label="结算方式"
			                              filter="true" filterMatchMode="startsWith" style="width:150px">
			            <f:selectItems value="#{bean.paytype}" />
			        </p:selectCheckboxMenu>
			        <p:selectCheckboxMenu id="menuAdvPosition" value="#{bean.selectedAdvPosition}" label="广告位置"
			                              filter="true" filterMatchMode="startsWith" style="width:150px">
			            <f:selectItems value="#{bean.advPosition}" />
			        </p:selectCheckboxMenu>
			        <p:commandLink id="ajax" value="高级查询" update="dlist12 :fsearch" action="#{bean.searchChannelData()}"/>
			    </h:panelGrid>
			    
			    <p:dataTable id="dlist12" var="l" value="#{bean.channelDatas}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}" rowsPerPageTemplate="15,30,100" rows="30" style="text-align:center;">
					<f:facet name="{Exporters}">
			        	<h:commandLink styleClass="exporter">
					        <p:graphicImage url="/resources/images/excel.png" height="25px"/>
					        <p:dataExporter type="xls" target="dlist12" fileName="payRangeData-#{pageHelper.getNewDateDetailStr()}"/>
					    </h:commandLink>
				    </f:facet>
					<p:column headerText="渠道名称" styleClass="column grcnewUser" sortBy="#{l.channelName}">
						<h:outputLabel value="#{l.channelName}" />
					</p:column>
					<p:column headerText="代理商" styleClass="column grcnewUser" sortBy="#{l.agentName}">
						<h:outputLabel value="#{l.agentName}" />
					</p:column>
					<p:column headerText="点击设备" styleClass="column grcnewUser" sortBy="#{l.clkEquipment}">
						<h:outputLabel value="#{l.clkEquipment}" />
					</p:column>
					<p:column headerText="激活设备" styleClass="column grcnewUser" sortBy="#{l.actEquipment}">
						<h:outputLabel value="#{l.actEquipment}" />
					</p:column>
					<p:column headerText="实际激活" styleClass="column grcnewUser" sortBy="#{l.newActive}">
						<h:outputLabel value="#{l.newActive}" />
					</p:column>
					<p:column headerText="新增设备" styleClass="column grcnewUser" sortBy="#{l.newEquipment}">
						<h:outputLabel value="#{l.newEquipment}" />
					</p:column>
					<p:column headerText="新增/激活" styleClass="column grcnewUser" sortBy="#{l.accountActive}">
						<h:outputLabel value="#{l.accountActive}" />
					</p:column>
					<p:column headerText="新增账号数" styleClass="column grcnewUser" sortBy="#{l.newAccount}">
						<h:outputLabel value="#{l.newAccount}" />
					</p:column>
					<p:column headerText="新增付费账号" styleClass="column grcnewUser" sortBy="#{l.newPayAccount}">
						<h:outputLabel value="#{l.newPayAccount}" />
					</p:column>
					<p:column headerText="新增付费金额" styleClass="column grcnewUser" sortBy="#{l.newPay}">
						<h:outputLabel value="#{l.newPay}" />
					</p:column>
					<p:column headerText="新增付费率" styleClass="column grcnewUser" sortBy="#{l.newPayRate}">
						<h:outputLabel value="#{l.newPayRate}" />
					</p:column>
					<p:column headerText="ARPU" styleClass="column grcnewUser" sortBy="#{l.arpu}">
						<h:outputLabel value="#{l.arpu}" />
					</p:column>
					<p:column headerText="操作" styleClass="column grcnewUser" style="text-align:center">
						<p:commandLink update=":dform:channellist" actionListener="#{bean.searchChannelDetail(l.channelName,l.agentName)}" oncomplete="PF('channelDialog').show()" >
					        <h:outputText value="查看详细" />
					    </p:commandLink>
					</p:column>
				</p:dataTable>
				<p:dialog header="渠道详细" widgetVar="channelDialog" modal="true" showEffect="fade" hideEffect="fade" resizable="false" position="top" width="75%">
			        <p:dataTable id="channellist" var="l" value="#{bean.payMinDatas}" scrollable="true" resizableColumns="true" paginator="true" paginatorPosition="top" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown} {Exporters}" rowsPerPageTemplate="15,30,100" rows="30" style="text-align:center;">
						<p:column headerText="时间" styleClass="column grcnewUser" sortBy="#{l.dateStr}">
							<h:outputLabel value="#{l.dateStr}" />
						</p:column>
						<p:column headerText="广告url" styleClass="column grcnewUser" sortBy="#{l.url}">
							<h:outputLabel value="#{l.url}" />
						</p:column>
						<p:column headerText="广告名称" styleClass="column grcnewUser" sortBy="#{l.advName}">
							<h:outputLabel value="#{l.advName}" />
						</p:column>
						<p:column headerText="点击设备" styleClass="column grcnewUser" sortBy="#{l.clkEquipment}">
							<h:outputLabel value="#{l.clkEquipment}" />
						</p:column>
						<p:column headerText="激活设备" styleClass="column grcnewUser" sortBy="#{l.actEquipment}">
							<h:outputLabel value="#{l.actEquipment}" />
						</p:column>
						<p:column headerText="实际激活" styleClass="column grcnewUser" sortBy="#{l.newActive}">
							<h:outputLabel value="#{l.newActive}" />
						</p:column>
						<p:column headerText="新增设备" styleClass="column grcnewUser" sortBy="#{l.newEquipment}">
							<h:outputLabel value="#{l.newEquipment}" />
						</p:column>
						<p:column headerText="新增/激活" styleClass="column grcnewUser" sortBy="#{l.accountActive}">
							<h:outputLabel value="#{l.accountActive}" />
						</p:column>
						<p:column headerText="新增账号数" styleClass="column grcnewUser" sortBy="#{l.newAccount}">
							<h:outputLabel value="#{l.newAccount}" />
						</p:column>
						<p:column headerText="新增付费账号" styleClass="column grcnewUser" sortBy="#{l.newPayAccount}">
							<h:outputLabel value="#{l.newPayAccount}" />
						</p:column>
						<p:column headerText="新增付费金额" styleClass="column grcnewUser" sortBy="#{l.newPay}">
							<h:outputLabel value="#{l.newPay}" />
						</p:column>
						<p:column headerText="新增付费率" styleClass="column grcnewUser" sortBy="#{l.newPayRate}">
							<h:outputLabel value="#{l.newPayRate}" />
						</p:column>
						<p:column headerText="ARPU" styleClass="column grcnewUser" sortBy="#{l.arpu}">
							<h:outputLabel value="#{l.arpu}" />
						</p:column>
					</p:dataTable>
			    </p:dialog>
    		</p:panel>
		</div>
	</h:form>
	<!-- 页脚 -->
	<div class="footer"></div>
</h:body>
</html>
